package com.xkdx.guangguang.fragment.home;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.xkdx.guangguang.module.network.AbsModule;
import com.xkdx.guangguang.shareclass.DiscountInfo;

/**
 * Created by z.yuan on 2014/11/11.
 */
public class RecommendModule extends AbsModule {
    public List<DiscountInfo> nearInfoList;
    private JSONObject jsonObject;

    @Override
    public void parseData() throws Exception {
        if (result != null) {
            jsonObject = (((JSONArray) result).getJSONObject(0)).getJSONObject("Content").getJSONObject("Result");

            if ("Success".equals(jsonObject.getString("Status"))) {
                JSONArray jsonArray = jsonObject.getJSONArray("ListInfo");
                nearInfoList = new ArrayList<DiscountInfo>();
                for (int i = 0; i < jsonArray.length(); i++) {
                    DiscountInfo discountInfo = new DiscountInfo();
                    JSONObject object = jsonArray.getJSONObject(i);
                    discountInfo.setInfoID(object.getString("InfoID"));
                    discountInfo.setInfoTitle(object.getString("InfoTitle"));
                    discountInfo.setInfoType(object.getString("InfoType"));
                    discountInfo.setBeginTime(object.getString("BeginTime"));
                    discountInfo.setEndTime(object.getString("EndTime"));
                    discountInfo.setPictrueUrl(object.getString("PictureUrl"));
//                    discountInfo.setDistance(object.getString("Distance"));
                    discountInfo.setShopName(object.getString("ShopName"));
                    nearInfoList.add(discountInfo);
                }
            }
        }
    }
}
